package manyAnimal;

public class Duck extends Animal implements Terrestrial{
    private int legNum;
    public Duck(String name,int legNum) {
        super(name);
        this.legNum = legNum;
    }

    public int getLegNum() {
        return legNum;
    }

    public void setLegNum(int legNum) throws illegalLegNumException {
        if (legNum != 2 ){
            throw new illegalLegNumException("鸭腿两只哦");
        }else {
            this.legNum = legNum;
        }
    }

    @Override
    public String shout() {
        return "我们一起学鸭叫,一起嘎嘎嘎嘎嘎~";
    }
    public void show(){
        System.out.println(this.getName()+"\t\t\t"+this.getLegNum()+"\t\t\t"+shout());
    }
}
